import request from '@/utils/request'

// 查询用户列表
export function getUserListPage(data) {
  return request({
    url: '/user/list',
    method: 'post',
    data: {
      page: data.page,
      count: data.count
    }
  })
}
// 查询用户
export function getListPage(data) {
  return request({
    url: '/user/search',
    method: 'post',
    data: data
  })
}

// 删除某个用户
export function removeUser(data) {
  return request({
    url: '/user/remove',
    method: 'post',
    data: data
  })
}

// 批量删除用户
export function batchRemoveUser(data) {
  console.log(data)
  return request({
    url: '/user/remove/batch',
    method: 'post',
    data: {
      ids: data
    }
  })
}

// 编辑用户
export function editUser(data) {
  return request({
    url: '/user/edit',
    method: 'post',
    data: data
  })
}

// 新增用户
export function addUser(data) {
  return request({
    url: '/user/add',
    method: 'post',
    data: data
  })
}

// 增加某个用户的权限配置 参数应该带上选择的id
export function addPermission(usernames, userPermissions) {
  console.log(usernames)
  console.log(userPermissions)
  return request({
    url: '/user/add/permissions',
    method: 'post',
    data: {
      userIds: usernames,
      permissionIds: userPermissions
    }
  })
}

// 显示角色配置列表
export function getRolesListPage() {
  return request({
    url: '/role/select/list',
    method: 'get'
  })
}

// 增加某个用户的角色配置 参数应该带上选择的label
export function addRoles(userIds, userRoles) {
  return request({
    url: '/user/add/roles',
    method: 'post',
    data: {
      userIds: userIds,
      roleIds: userRoles
    }
  })
}

export function getDepartmentCascader(id) {
  return request({
    url: 'department/tree/cascade',
    method: 'get'
  })
}

export function getOption() {
  return request({
    url: 'user/option',
    method: 'get'
  })
}

export function getPositions(userId) {
  return request({
    url: 'user/positions',
    method: 'get',
    params: {
      userId: userId
    }
  })
}
